class Solution {
public:
    int climbStairs(int n) 
    {
        if (n <= 2)
            return n;

        else
        {
            int i1 = 1;
            int i2 = 2;
            int res = 0;

            for(int i = 3; i <= n; i++)
            {
                
                res = i1 + i2;
                i1 = i2;
                i2 = res;  
            }
            
            return res;
        } 
       
    }
};

//使用斐波那契数列进行计算，执行用时和内存消耗表现最好